package codeTop;

public class q206 {
    public ListNode reverseList(ListNode head) {
        if (head == null) {
            return null;
        }
        ListNode p = head;
        ListNode next  = head.next;
        p.next = null;
        while (next!=null){
            ListNode temp = next.next;
            next.next = p;
            p = next;
            next = temp;
        }
        return p;
    }
}

